'''
Created on 2010/07/06

@author: yukiyonezawa
'''

import re  
  
class AccessMethod(object):
    
    '''
    classdocs
    '''
    call_back_instance = object()
    
    def __init__(self):
        '''
        Constructor
        '''
        pass


    @staticmethod
    def getAccessMethod(access_method_id):

        #create instance of access method
        if access_method_id == NonDirectory.ACCESS_METHOD_ID:
            return NonDirectory()
        elif  access_method_id == Directory.ACCESS_METHOD_ID:
            return Directory()
        elif  access_method_id == PackedObjects.ACCESS_METHOD_ID:
            return PackedObjects()
        elif  access_method_id == TagDataProfile.ACCESS_METHOD_ID:                        
            return TagDataProfile()
    
    
    @staticmethod
    def convertIntToStringHex(self, intValue, minLength = 2):
        hexValue = re.sub('0x', '', hex(intValue))
        if len(hexValue) > minLength:
            raise "ERROR length is not mutch"
        if len(hexValue) < minLength:
            hexValue = hexValue.zfill(minLength)
        return hexValue
    
#    def setCallBackForAddingData(self, call_back_class):
#        self.call_back_instance = call_back_class
#    def getCallBackForAddingData(self):
#        return self.call_back_instance
    
from pyrfid.DataProtocol.DSFID.AccessMethod.NonDirectory import NonDirectory 
from pyrfid.DataProtocol.DSFID.AccessMethod.Directory import Directory 
from pyrfid.DataProtocol.DSFID.AccessMethod.TagDataProfile import TagDataProfile 
from pyrfid.DataProtocol.DSFID.AccessMethod.PackedObjects.PackedObjects import PackedObjects
